package com.qzsoft.zhjd.server.handler;

import com.qzsoft.zhjd.server.common.utils.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 功能描述: 统一异常处理
 *
 * @author : liugf
 * @date : 2020/6/9 12:09
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler(value = BizException.class)
    public R bizExceptionErrorHandler(BizException ex) {
        ex.printStackTrace();
        return R.error(ex.getCode(), ex.getMessage());
    }

    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public R exceptionErrorHandler(Exception ex) {
        ex.printStackTrace();
        return R.error();
    }

}
